<?php
if (isset($_COOKIE["ImOnline"])){
	//print($_COOKIE["ImOnline"]);
	//print("Welcome back " . $_COOKIE["Username"]);
} else {
	die("<br>You have no access to this page. <br><a href=\"index.php\">Please go to main page</a>");
	//print($_COOKIE["imonline"]);
	};
include("../config.php");
$q=$_GET["q"];

$con = mysql_connect($host, $username, $password);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db($db, $con);
if($q == -1){
	$sql="SELECT * FROM Users";
}else{
$sql="SELECT * FROM Users WHERE Status = '".$q."'";
};
$result = mysql_query($sql);

echo "<table border='0'>
<tr>
<th>Actions</th>
<th>Ingame Nick&nbsp;&nbsp;</th>
<th>Steam-ID&nbsp;&nbsp;</th>
<th>Username&nbsp;&nbsp;</th>
<th>Kills&nbsp;&nbsp;</th>
<th>Deaths&nbsp;&nbsp;</th>
<th>Banmarks&nbsp;&nbsp;</th>
<th>Status</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
	if ($row['Status'] == 1) {
	$status = "VIP";	
	} elseif ($row['Status'] == 2) {
	$status = "Admin";		
	} elseif ($row['Status'] == 3) {
	$status = "Owner";	
	}else{
	$status = "Guest";	
	};
  echo "<tr>";
  echo "<td><a href=\"#\" onClick='OpenAjax(\"". $row['SteamID'] ."\",\"". $row['Nick'] ."\",\"". $row['Username'] ."\",\"status\",\"". $row['Status'] ."\")'><img src=\"images/icons/premium.png\" alt=\"Set Status\" \></a><a href=\"#\" onClick='OpenAjax(\"". $row['SteamID'] ."\",\"". $row['Nick'] ."\",\"". $row['Username'] ."\",\"ban\",\"". $row['Status'] ."\")'><img src=\"images/icons/busy.png\" alt=\"Ban\" \></a></td>";
  echo "<td>" . $row['Nick'] . "&nbsp;&nbsp;</td>";
  echo "<td>" . $row['SteamID'] . "&nbsp;&nbsp;</td>";
  echo "<td>" . $row['Username'] . "&nbsp;&nbsp;</td>";
  echo "<td>" . $row['Kills'] . "</td>";
  echo "<td>" . $row['Deaths'] . "</td>";
  echo "<td>" . $row['Banmarks'] . "</td>";
  echo "<td>" . $status . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>